<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<contextName>${project.name}</contextName>
	<jmxConfigurator />

	<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] [%X{klone.requestFlowNo}|%X{klone.consumerIp}] %logger{56}.%method\(\):%L - %msg%n</pattern>
		</layout>
	</appender>

	<appender name="file.all" class="ch.qos.logback.core.rolling.RollingFileAppender"><!-- All Log Info -->
		<File>/data/logs/${project.name}/${project.name}.log</File>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>/data/logs/${project.name}/${project.name}_all_%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>
		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] [%X{klone.requestFlowNo}|%X{klone.consumerIp}] %logger{56}.%method\(\): - %msg%n</pattern>
		</layout>
	</appender>

	<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
	<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
	<!-- 添加附加的appender,最多只能添加一个 -->
	<appender name="file.async" class="ch.qos.logback.classic.AsyncAppender">
		<discardingThreshold>0</discardingThreshold>
		<queueSize>256</queueSize>
		<includeCallerData>true</includeCallerData>
		<appender-ref ref="file.all" />
	</appender>

	<appender name="file.error" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<File>/data/logs/${project.name}/${project.name}_err.log</File>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>/data/logs/${project.name}/${project.name}_err_%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>

		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] [%X{klone.requestFlowNo}|%X{klone.consumerIp}] %logger{56}.%method\(\): - %msg%n</pattern>
		</layout>

		<filter class="ch.qos.logback.classic.filter.LevelFilter">
			<level>ERROR</level>
			<onMatch>ACCEPT</onMatch>
			<onMismatch>DENY</onMismatch>
		</filter>
	</appender>

	<appender name="file.info" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<File>/data/logs/${project.name}/${project.name}_info.log</File>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<FileNamePattern>/data/logs/${project.name}/${project.name}_info_%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
				<maxFileSize>100MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
		</rollingPolicy>

		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread] [%X{klone.requestFlowNo}|%X{klone.consumerIp}] %logger{56}.%method\(\): - %msg%n</pattern>
		</layout>

		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>INFO</level>
		</filter>
	</appender>

	<root level="INFO">
		<appender-ref ref="stdout" />
		<appender-ref ref="file.async" />
		<appender-ref ref="file.error" />
		<appender-ref ref="file.info" />
	</root>

	<!-- 以下日志打印输出请自行关闭开户，但上线请统一处理 -->
	<!-- <logger name="org.springframework" additivity="false"> -->
	<!-- <level value="debug" /> -->
	<!-- <appender-ref ref="file.async" /> -->
	<!-- <appender-ref ref="file.error" /> -->
	<!-- </logger> -->
</configuration>